type DebounceFunc<T extends (...args: any[]) => void> = (
    func: T,
    delay: number
  ) => (...args: Parameters<T>) => void;


export function getLastSevenDays(num:number):string[] {
    const dates:string[] = [];
    const today = new Date();
    for(let i = 0; i < num; i++ ){
        const date = new Date(today);
        date.setDate(today.getDate() + i);
        const formattedDate = date.toISOString().split('T')[0];
        dates.push(formattedDate);
    }

    return dates;
}



export const debounce: DebounceFunc<(...args: any[]) => void> = (func, delay) => {
    let timeoutId: NodeJS.Timeout | null = null;

    return (...args: any[]) => {
      if (timeoutId) {
        clearTimeout(timeoutId);
      }

      timeoutId = setTimeout(() => {
        func(...args);
      }, delay);
    };
  };





